"use strict"

/**
 * 太原市政府采购网爬虫
 *  
 */

var Base = require("./base");
var ty_spider = new Base();
ty_spider.name = "太原市采购网";
ty_spider.page = 1;
ty_spider.contentType = "text";

ty_spider.getPageUrl = function (pg) {
    return "http://www.tyzfcg.gov.cn/view.php?app=bid&type=A&id_name=&page=" + pg;
};

ty_spider.getItems = function (data) {
    var reg = new RegExp("onclick=\"fDetail\\((\\d+)\\)[\\s\\S]+?title='(.*?)'", "ig");
    var regv;
    var items = []
    while (regv = reg.exec(data)) {
        var id = regv[1];
        var title = regv[2];
        var item = {};
        item.title = title;
        item.url = "http://www.tyzfcg.gov.cn/view.php?app=bidDetail&id=" + id + ".html";
        item.source = ty_spider.name;
        items.push(item);
    }
    return items;
};

exports = module.exports = ty_spider;